package com.bdqn.web;

import java.io.IOException;
import java.io.PrintWriter;

import javax.jms.Session;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.bdqn.web.bojo.User;

public class User51Servlet extends HttpServlet {

	@Override
	protected void service(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		req.setCharacterEncoding("utf-8");
		resp.setContentType("text/html;charset=utf-8");
		String userName = req.getParameter("userName");
		String password = req.getParameter("password");

		HttpSession session = req.getSession();
		User user = (User) session.getAttribute("userName");
		String name = user.getUserName();
		String pwd = user.getPassword();
		if (name.equals(userName) && pwd.equals(password)) {
			resp.sendRedirect("welcome.jsp");
		} else {
			PrintWriter out = resp.getWriter();
			out.print("<script type='text/javascript'>"
					+ "alert('用户名或密码错误！，请重新输入！')"
					+ "location.href='email2.jsp';</script>");
			out.close();
		}
	}

}
